package org.zoomdev.zoom.common.filter.impl;

import org.zoomdev.zoom.common.filter.Filter;

/**
 * 所有过滤器中，只要有一个通过，就算通过
 *
 * @param <T>
 * @author jzoom
 */
public final class OrFilter<T> implements Filter<T> {

    private final Filter<T>[] filters;

    public OrFilter(Filter<T>... filters) {
        this.filters = filters;
    }

    @Override
    public boolean accept(T value) {
        for (Filter<T> filter : filters) {
            if (filter.accept(value)) {
                return true;
            }
        }
        return false;
    }

}
